package com.yellow.cloud.system.controller;

import com.yellow.cloud.system.service.LoginLogService;
import com.yellowframework.cloud.api.system.LoginLogControllerApi;
import com.yellowframework.cloud.common.annotation.FeignLogin;
import com.yellowframework.cloud.common.model.response.QueryResponseResult;
import com.yellowframework.cloud.domain.system.LoginLog;
import com.yellowframework.cloud.domain.system.ext.LoginLogExt;
import com.yellowframework.cloud.domain.system.request.QueryLoginLogRequest;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 系统登录日志
 *
 * @author Hao.
 * @email 15738383930@163.com
 * @since 2023-05-22 09:15:14
 */
@RestController
@RequestMapping("/sys/loginlog")
public class LoginLogController implements LoginLogControllerApi {

    @Resource
    private LoginLogService loginLogService;

    @Override
    @GetMapping("/page/list/{page}/{size}")
    @PreAuthorize("hasAuthority('sys:loginlog:list')")
    public QueryResponseResult<LoginLogExt> pageList(@PathVariable("page") Integer page, @PathVariable("size") Integer size, QueryLoginLogRequest request){
        return loginLogService.pageList(page, size, request);
    }

    @FeignLogin(client = false)
    @PostMapping
    public LoginLog saveLoginlog(@RequestBody LoginLog request) {
        return loginLogService.saveLoginLog(request);
    }

}
